<%-- <%@page import="com.liferay.portal.kernel.util.Constants"%>
<%@page import="qldc.pm.tienan.searchcontainer.DSTaiPhamSearch"%>
<%@page import="qldc.pm.tienan.searchcontainer.DSTaiPhamSearchTerms"%>
<%@page import="qldc.pm.qtht.dmdc.model.Tinh"%>
<%@page import="qldc.pm.qtht.dmdc.service.TinhLocalServiceUtil"%>
<%@page import="java.util.List"%>
<%@page import="qldc.pm.tienan.service.DoiTuongTienAnLocalServiceUtil"%>
<%@page import="qldc.pm.tienan.searchcontainer.DSTaiPhamDisplayTerms"%>
<%@page import="java.util.Date"%>
<%@page import="com.liferay.portal.kernel.util.StringPool"%>
<%@page import="java.text.SimpleDateFormat"%>

<%@include file="../../init.jsp"%>

<%
	PortletURL portletURL = renderResponse.createRenderURL();
	portletURL.setParameter("mvcPath", "/html/view.jsp");
	portletURL.setParameter("chonChucNangItem",
			TienAnConstants.DS_BKTT);
	portletURL.setParameter("loaiBKTK",
			TienAnConstants.DS_TAI_PHAM);
	PortletURL thoatUrl =  renderResponse.createRenderURL();
	thoatUrl.setParameter("mvcPath", "/html/view.jsp");
	thoatUrl.setParameter("chonChucNangItem",
	TienAnConstants.BAO_CAO_THONG_KE);
	String pathThemeImages = themeDisplay.getPathThemeImages();
	
%>

<portlet:resourceURL var="loadQuanHuyen" id="loadQuanHuyen">
	<portlet:param name="tinhIdSelected" value="{0}" />
</portlet:resourceURL>

<portlet:resourceURL var="loadPhuongXa" id="loadPhuongXa">
	<portlet:param name="quanHuyenIdSelected" value="{0}" />
</portlet:resourceURL>


<script type="text/javascript">
var NhapNgay = (function() {
	function NhapNgay() {}
	/*
	 * 
	 */
	 NhapNgay.prototype.initCalendars = function() {
			$("#<portlet:namespace/>tuNgayPhamToi").datepicker({
				showOn: "button",
				buttonImage: "<%=pathThemeImages%>/common/calendar.png",
					buttonImageOnly : true,
					buttonText : "<liferay-ui:message key="tuNgayPhamToi" />",
					dateFormat : "dd/mm/yy",
					onClose: function( selectedDate ) {
						 $("#<portlet:namespace/>denNgayPhamToi").datepicker( "option", "minDate", selectedDate );
						 }
				});
			$("#<portlet:namespace/>denNgayPhamToi").datepicker({
				showOn: "button",
				buttonImage: "<%=pathThemeImages%>/common/calendar.png",
					buttonImageOnly : true,
					buttonText : "<liferay-ui:message key="denNgayPhamToi" />",
					dateFormat : "dd/mm/yy",
					onClose: function( selectedDate ) {
						 $("#<portlet:namespace/>tuNgayPhamToi").datepicker( "option", "maxDate", selectedDate );
						 }
				});

		};

		return NhapNgay;
	})();

	$(function() {
		var dom = new NhapNgay();

		dom.initCalendars();
	});
</script>


<fieldset>
	<legend>
		<liferay-ui:message key="danh-sach-doi-tuong-tai-pham" />
	</legend>
	<form action="<%=portletURL.toString()%>" method="POST">
		<%
			SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
			DSTaiPhamSearch dSTaiPhamSearch = new DSTaiPhamSearch(renderRequest,
					portletURL);
			DSTaiPhamDisplayTerms displayTerms = (DSTaiPhamDisplayTerms) dSTaiPhamSearch
					.getDisplayTerms();
			DSTaiPhamSearchTerms searchTerms = (DSTaiPhamSearchTerms) dSTaiPhamSearch
					.getSearchTerms();
			int sttDoiTuong = dSTaiPhamSearch.getDelta() * (dSTaiPhamSearch.getCur() - 1);
			long noiThuongTruTinhIdSelected = searchTerms.getTinhId();
			long noiThuongTruQuanHuyenIdSelected = searchTerms.getQuanHuyenId();
			long noiThuongTruPhuongXaIdSelected = searchTerms.getPhuongXaId();
			PortletURL inReportURL = renderResponse.createActionURL();
			inReportURL.setParameter(TienAnConstants.ACTION_HANDLER_PARAM, TienAnConstants.REPORT_ACTION);
			inReportURL.setParameter(Constants.ACTION, "inReportDSTaiPham");
			inReportURL.setParameter("redirect", portletURL.toString());
			inReportURL.setParameter("loaiBKTK",
					TienAnConstants.DS_TAI_PHAM);
			inReportURL.setParameter("tuNgayPhamToi", displayTerms.getTuNgayNhanHoSo() != null ? displayTerms.getTuNgayNhanHoSo().toLocaleString() : "");
			inReportURL.setParameter("denNgayPhamToi", displayTerms.getDenNgayNhanHoSo() != null ? displayTerms.getDenNgayNhanHoSo().toLocaleString() : "");
			inReportURL.setParameter("tinhId", String.valueOf(displayTerms.getTinhId()));
			inReportURL.setParameter("quanHuyenId", String.valueOf(displayTerms.getQuanHuyenId()));
			inReportURL.setParameter("phuongXaId", String.valueOf(displayTerms.getPhuongXaId()));
			inReportURL.setParameter("diaChi", displayTerms.getDiaChi());
			inReportURL.setParameter("start", String.valueOf(dSTaiPhamSearch.getStart()));
			inReportURL.setParameter("end", String.valueOf(dSTaiPhamSearch.getEnd()));
		%>
		<table class="gridnormal">


			<tr>
				<td><liferay-ui:message key="noi-thuong-tru" /></td>

				<td colspan="2"><select class="display-inline" style="width: 30%" name="<portlet:namespace/>noiThuongTruTinhId" id="<portlet:namespace/>noiThuongTruTinhId"
					onchange="loadQuanHuyen('<portlet:namespace />noiThuongTruTinhId', '<portlet:namespace />noiThuongTruQuanHuyenId', '<portlet:namespace />noiThuongTruPhuongXaId', '<%=loadQuanHuyen.toString()%>','<%=noiThuongTruQuanHuyenIdSelected%>');">
						<%
							List<Tinh> tinhs = TinhLocalServiceUtil.findAll();

							for (Tinh tinh : tinhs) {
						%>
						<option value="<%=tinh.getTinhId()%>" <%=(noiThuongTruTinhIdSelected == tinh.getTinhId() || tinh
						.isLaMacDinh()) ? "selected=selected"
						: StringPool.BLANK%>><%=tinh.getTenTinh()%></option>
						<%
							}
						%>
				</select> <select class="display-inline" style="width: 30%" name="<portlet:namespace/>noiThuongTruQuanHuyenId" id="<portlet:namespace/>noiThuongTruQuanHuyenId" onchange="loadPhuongXa('<portlet:namespace/>noiThuongTruQuanHuyenId', '<portlet:namespace/>noiThuongTruPhuongXaId', '<%=loadPhuongXa.toString()%>', '<%=noiThuongTruPhuongXaIdSelected%>');"></select>

					<select class="display-inline" style="width: 30%" name="<portlet:namespace/>noiThuongTruPhuongXaId" id="<portlet:namespace/>noiThuongTruPhuongXaId"></select></td>
				<td><input type="text" name="<portlet:namespace/>noiThuongTruDiaChi" id="<portlet:namespace/>noiThuongTruDiaChi" value="<%=searchTerms.getDiaChi()%>" /></td>
			</tr>

			<tr>
				<td class="txtlabel aui-w20"><liferay-ui:message key="tu-ngay-pham-toi" /></td>
				<td class="aui-w30"><input type="text" id="<portlet:namespace/>tuNgayPhamToi" name="<portlet:namespace/>tuNgayPhamToi" value="<%=displayTerms.getTuNgayNhanHoSo() != null ? displayTerms
					.getTuNgayNhanHoSo() : ""%>" /></td>
				<td class="txtlabel aui-w20"><liferay-ui:message key="den-ngay-pham-toi" /></td>
				<td class="aui-w30"><input type="text" id="<portlet:namespace/>denNgayPhamToi" name="<portlet:namespace/>denNgayPhamToi" value="<%=displayTerms.getDenNgayNhanHoSo() != null ? displayTerms
					.getDenNgayNhanHoSo() : ""%>" /></td>
			</tr>
		</table>
		<div align="left">
			<input type=submit  class="btn btn-primary" name="<portlet:namespace/>Tim" value="<liferay-ui:message key="tim" />" /> <input type=button class="btn"  name="<portlet:namespace/>in" value="In"  onclick="inDuLieu('<%= inReportURL.toString() %>');" />
			<input type=button class="btn"  name="<portlet:namespace/>thoat" value="Thoat"  onclick="window.location = '<%=thoatUrl.toString() %>';" />
		</div>
	</form>

	<liferay-ui:search-container emptyResultsMessage="khong-tim-thay-doi-tuong-nao">
		<liferay-ui:search-container-results>
			<%
				results = DoiTuongTienAnLocalServiceUtil.findByDS_TaiPham(
								searchTerms.getTinhId(),
								searchTerms.getQuanHuyenId(),
								searchTerms.getPhuongXaId(),
								searchTerms.getDiaChi(),
								searchTerms.getTuNgayNhanHoSo(),
								searchTerms.getDenNgayNhanHoSo(),
								dSTaiPhamSearch.getStart(), dSTaiPhamSearch.getEnd());

						total = DoiTuongTienAnLocalServiceUtil.countByDS_TaiPham(searchTerms.getTinhId(),
								searchTerms.getQuanHuyenId(),
								searchTerms.getPhuongXaId(),
								searchTerms.getDiaChi(),
								searchTerms.getTuNgayNhanHoSo(),
								searchTerms.getDenNgayNhanHoSo());

						pageContext.setAttribute("results", results);
						pageContext.setAttribute("total", total);
			%>
		</liferay-ui:search-container-results>
		

		
		
		<liferay-ui:search-container-row className="qldc.pm.tienan.dto.DS_TaiPhamDTO" keyProperty="soDinhDanhCaNhan" modelVar="doiTuong">
			<liferay-ui:search-container-column-text name="stt" value="<%=String.valueOf(sttDoiTuong++)%>" />
			<liferay-ui:search-container-column-text name="so-so-ho-khau" value="<%=doiTuong.getSoSoHoKhau()%>" />
			<liferay-ui:search-container-column-text name="dia-chi-thuong-tru" value="<%=doiTuong.getDiaChi()%>" />
			<liferay-ui:search-container-column-text name="ho-va-ten" value="<%=doiTuong.getHoVaTen()%>" />
			<liferay-ui:search-container-column-text name="so-dinh-danh" value="<%=doiTuong.getSoDinhDanhCaNhan()%>" />
			<liferay-ui:search-container-column-text name="so-cmnd" value="<%=doiTuong.getSoCMND()%>" />
			<liferay-ui:search-container-column-text name="ngay-pham-toi" value="<%=doiTuong.getNgayPhamToi()%>" />
			<liferay-ui:search-container-column-text name="toi-danh" value="<%=doiTuong.getToiDanh()%>" />
			<liferay-ui:search-container-column-text name="toi-danh-truoc" value="<%=doiTuong.getToiDanhTruoc()%>" />
			<liferay-ui:search-container-column-text name="ngay-pham-toi-truoc" value="<%=doiTuong.getNgayPhamToiTruoc()%>" />
			<liferay-ui:search-container-column-text name="ngay-xoa-an-tich" value="<%=doiTuong.getNgayXoaAnTich()%>" />
			<liferay-ui:search-container-column-text name="nhan-xet" value="<%=doiTuong.getNhanXet()%>" />
		</liferay-ui:search-container-row>

		<liferay-ui:search-iterator searchContainer="<%=dSTaiPhamSearch%>" />
	</liferay-ui:search-container>
<script type="text/javascript">
$(function() {
	 loadQuanHuyen('<portlet:namespace />noiThuongTruTinhId', '<portlet:namespace />noiThuongTruQuanHuyenId', '<portlet:namespace />noiThuongTruPhuongXaId', '<%=loadQuanHuyen.toString() %>','<%=noiThuongTruQuanHuyenIdSelected %>');
	 loadPhuongXa('<portlet:namespace/>noiThuongTruQuanHuyenId', '<portlet:namespace/>noiThuongTruPhuongXaId', '<%=loadPhuongXa.toString() %>', '<%=noiThuongTruPhuongXaIdSelected %>');
});

function inDuLieu(url){
	var form = $("<form>").attr({action: url, method:"POST",target:"_blank"});				
	form.appendTo(document.body).submit();
	
}
</script>
</fieldset>

 --%>